package com.czkt.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.czkt.mapper.SysRoleRightMapper;
import com.czkt.mapper.SysUserMpper;
import com.czkt.pojo.SysRight;
import com.czkt.pojo.SysRoleRight;
import com.czkt.pojo.SysUser;
import com.czkt.pojo.vo.SysUserVo;
import com.czkt.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMpper, SysUser> implements SysUserService {

    @Autowired
    SysUserMpper sysUserMpper;

    @Autowired
    SysRoleRightMapper sysRoleRightMapper;

    @Override
    public SysUserVo login(String usrName, String pwd) {

        return   sysUserMpper.login(usrName,pwd);
    }

    @Override
    public SysUserVo login(String usrName) {
        return sysUserMpper.loginByName(usrName);
    }

    @Override
    public IPage<SysUserVo> getPage(IPage<SysUserVo> page,SysUserVo sysUserVo) {
        return sysUserMpper.getPage(page, sysUserVo);
    }

    @Override
    public List<SysRoleRight> getRightListByRoleId(long roleId) {
        LambdaQueryWrapper<SysRoleRight> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(roleId!=0,SysRoleRight::getRfRoleId,roleId);
        return sysRoleRightMapper.selectList(queryWrapper);
    }

    @Override
    public List<SysRight> getRightsByRoleId(long roleId) {




        return null;
    }


}
